package com.example.Words.room.model;

import android.app.Application;

import androidx.lifecycle.LiveData;

import com.example.Words.room.model.entity.Word;
import com.example.Words.room.model.storage.repository.WordRepository;

import java.util.List;

/**
 * <pre>
 *  author:huletian
 *  time    :2020/2/22
 *  desc    :模型层实现
 *  version:1.0
 * </pre>
 */
public class RoomModelImp implements RoomModeIIntf{
    WordRepository wordRepository;
    public RoomModelImp(Application application){
        wordRepository=new WordRepository(application);
    }
    public void insertDate(Word... words){
        wordRepository.insertWords(words);
    }
    public void update(Word... words){
        wordRepository.updateWords(words);
    }
    public void clearDate(){
        wordRepository.deleteAllWords();
    }
    public LiveData<List<Word>> getAllWordsLive() {
        return wordRepository.getAllWordsLive();
    }

    @Override
    public LiveData<List<Word>> findWordsWithPatten(String patten) {
        return wordRepository.findWordsWithPatten(patten);
    }

    @Override
    public void deleteData(Word... words) {
        wordRepository.deleteWords(words);
    }
}
